// pages/my/inventoryRecord/inventoryRecord.js
const app = getApp()
Page({
  data: {
    list:[],
    isNote:false,
    note:''
  },
  onLoad: function (options) {
    let skuId = options.id
    this.getRecord(skuId)
  },
  onShow: function () {

  },
  getRecord(skuId){
    let data = {
      skuId
    }
    app.request('wx_app/agent/stock/skuStockRecord/findBySkuId',data,'GET').then(res=>{
      console.log(res)
      let list = []
      res.data.forEach(item=>{
        list.push({
          day:item.createdStr.split(' ')[0],
          time:item.createdStr.split(' ')[1],
          before:item.changeForward,
          after:item.changeBack,
          note:item.note,
          id:item.id
        })
      })
      this.setData({
        list
      })
    })
  },
  bindLookNote(e){
    let id = e.currentTarget.dataset.id
    console.log(id)
    this.data.list.forEach(item=>{
      if (id==item.id) {
        this.setData({
          note:item.note
        })
      }
    })
    this.setData({
      isNote:true
    })
  },
  bindCloseNote(){
    this.setData({
      isNote:false
    })
  }
})